//      hotkeys.c
//      
//      Copyright 2011 DJ Shaji <djshaji@gmail.com>
//      
//      This program is free software; you can redistribute it and/or modify
//      it under the terms of the GNU General Public License as published by
//      the Free Software Foundation; either version 2 of the License, or
//      (at your option) any later version.
//      
//      This program is distributed in the hope that it will be useful,
//      but WITHOUT ANY WARRANTY; without even the implied warranty of
//      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//      GNU General Public License for more details.
//      
//      You should have received a copy of the GNU General Public License
//      along with this program; if not, write to the Free Software
//      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
//      MA 02110-1301, USA.


#include "hotkeys.h"
#include "explorer.h"

void hotkeys ( GtkWidget * widget, GdkEventKey * event, Explorer * e )
{
	switch ( event -> keyval )
	{
		case 65383:
		case GDK_Super_L:
		case GDK_Super_R:

			fm_pop_menu ( e -> iconview, event, e ) ;
			break ;

		case 'a':
			if ( event -> state != GDK_CONTROL_MASK )
				break ;
			
			if ( event -> state != GDK_SHIFT_MASK )
				gtk_icon_view_select_all ( e -> iconview ) ;
			else
				gtk_icon_view_unselect_all ( e -> iconview ) ;
				
			break ;


		case 'c':
			if ( event -> state != GDK_CONTROL_MASK )
				break ;
				
			explorer_copy_to_clipboard ( e, COPY ) ;
			explorer_set_status_message ( e, "Files copied to clipboard" ) ;

			break ;
		case 'v':
			if ( event -> state != GDK_CONTROL_MASK )
				break ;

			explorer_paste_from_clipboard ( e ) ;
			explorer_set_status_message ( e, "Files pasted from clipboard" ) ;	
			
			break ;
			
		case 'r':
			if ( event -> state != GDK_CONTROL_MASK )
				break ;

		case GDK_F5:
			fm_refresh ( e ) ;
			break ;
			
		case GDK_Delete:
			if ( event -> state != GDK_CONTROL_MASK )
				break ;

			explorer_delete_selected_files ( e ) ;
			break ;
			
		if ( event -> state == GDK_MOD1_MASK )
		{
			case GDK_Up:
				fm_go_up ( e ) ;
				break ;
			case GDK_Left:
				fm_go_back ( e ) ;
				break ;
			
		}
		
		case GDK_Escape:
			explorer_fire_event ( e ) ;
			break ;
		
		default:
			break ;
	}
	
}
